package com.easy.controller;


import com.easy.bean.Room_maintenance;
import com.easy.service.Room_maintenanceService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin//允许跨域访问
@RequestMapping("room_maintenance")
public class Room_maintenanceController {
    @Autowired
    Room_maintenanceService room_maintenanceService;

    @PostMapping
    public Result add(@RequestBody Room_maintenance room_maintenance) {
        Object obj = room_maintenanceService.add(room_maintenance);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Room_maintenance room_maintenance) {
        Object obj = room_maintenanceService.edit(room_maintenance);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable(name = "id") Integer id) {
        Object obj = room_maintenanceService.del(id);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id) {
        Object obj = room_maintenanceService.one(id);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Room_maintenance room_maintenance) {
        Object obj = room_maintenanceService.all(room_maintenance);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(Page page, Room_maintenance room_maintenance) {
        room_maintenanceService.page(page, room_maintenance);
        return Result.success(page);
    }
}